﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SuperCalculator
{
    public class FunctionInfoCollection : ICollection
    {
        private ArrayList alCollection = new ArrayList();

        /// <summary>
        /// 索引器。
        /// </summary>
        /// <param name="index">索引号。</param>
        /// <returns></returns>
        public FunctionInfo this[int index]
        {
            get { return (FunctionInfo) alCollection[index]; }
            set { alCollection[index] = value; }
        }

        /// <summary>
        /// 添加元素到集合。
        /// </summary>
        /// <param name="fInfo">要添加的FunctionInfo对象。</param>
        /// <returns></returns>
        public int Add(FunctionInfo fInfo)
        {
            return alCollection.Add(fInfo);
        }

        /// <summary>
        /// 从集合中移除特定元素的第一个匹配项。
        /// </summary>
        /// <param name="fInfo">要移除的FunctionInfo对象。</param>
        public void Remove(FunctionInfo fInfo)
        {
            alCollection.Remove(fInfo);
        }

        #region ICollection成员

        public void CopyTo(Array array, int index)
        {
            alCollection.CopyTo(array, index);
        }

        public int Count => alCollection.Count;

        public bool IsSynchronized => false;

        public object SyncRoot => this;

        #endregion

        #region IEnumerable成员

        public IEnumerator GetEnumerator()
        {
            return alCollection.GetEnumerator();
        }

#endregion
    }
}
